<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- Transactional memory for sequential implementations.</span><span>
</span><span id="line-2"></span><span class="hs-comment">-- Transactions do not run concurrently, but are atomic in the face</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- of exceptions.</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &gt;= 709
</span><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span class="hs-cpp">
#elif __GLASGOW_HASKELL__ &gt;= 701
</span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- #hide</span><span>
</span><span id="line-14"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Control.Sequential.STM</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier">STM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#atomically"><span class="hs-identifier">atomically</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#throwSTM"><span class="hs-identifier">throwSTM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#catchSTM"><span class="hs-identifier">catchSTM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier">TVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#newTVar"><span class="hs-identifier">newTVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#newTVarIO"><span class="hs-identifier">newTVarIO</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#readTVar"><span class="hs-identifier">readTVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#readTVarIO"><span class="hs-identifier">readTVarIO</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#writeTVar"><span class="hs-identifier">writeTVar</span></a></span><span>
</span><span id="line-17"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &lt; 705
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Prelude</span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">catch</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">#if __GLASGOW_HASKELL__ &lt; 709
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Applicative</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Applicative</span><span class="hs-special">(</span><span class="hs-identifier">pure</span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-operator">&lt;*&gt;</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.IORef.html#"><span class="hs-identifier">Data.IORef</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-comment">-- The reference contains a rollback action to be executed on exceptions</span><span>
</span><span id="line-29"></span><span class="hs-keyword">newtype</span><span> </span><span id="STM"><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span></span><span> </span><span id="local-6989586621679037971"><span class="annot"><a href="#local-6989586621679037971"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="STM"><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IORef.html#IORef"><span class="hs-identifier hs-type">IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679037971"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span id="local-6989586621679037981"><span class="annot"><a href="Control.Sequential.STM.html#unSTM"><span class="hs-identifier hs-type">unSTM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037981"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IORef.html#IORef"><span class="hs-identifier hs-type">IORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679037981"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-32"></span><span id="unSTM"><span class="annot"><span class="annottext">unSTM :: forall a. STM a -&gt; IORef (IO ()) -&gt; IO a
</span><a href="Control.Sequential.STM.html#unSTM"><span class="hs-identifier hs-var hs-var">unSTM</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span id="local-6989586621679037885"><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037885"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037885"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679037882"><span class="annot"><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-type">Functor</span></a></span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-35"></span><span>    </span><span id="local-6989586621679037878"><span class="annot"><span class="annottext">fmap :: forall a b. (a -&gt; b) -&gt; STM a -&gt; STM b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var hs-var hs-var hs-var">fmap</span></a></span></span><span> </span><span id="local-6989586621679037877"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679037877"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span id="local-6989586621679037876"><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037876"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IORef (IO ()) -&gt; IO b) -&gt; STM b
forall a. (IORef (IO ()) -&gt; IO a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; IO a -&gt; IO b
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679037877"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">(IO a -&gt; IO b) -&gt; (IORef (IO ()) -&gt; IO a) -&gt; IORef (IO ()) -&gt; IO b
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037876"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679037865"><span id="local-6989586621679037867"><span id="local-6989586621679037869"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-38"></span><span>    </span><span id="local-6989586621679037861"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; STM a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IORef (IO ()) -&gt; IO a) -&gt; STM a
forall a. (IORef (IO ()) -&gt; IO a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="annot"><span class="annottext">((IORef (IO ()) -&gt; IO a) -&gt; STM a)
-&gt; (a -&gt; IORef (IO ()) -&gt; IO a) -&gt; a -&gt; STM a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">IO a -&gt; IORef (IO ()) -&gt; IO a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">(IO a -&gt; IORef (IO ()) -&gt; IO a)
-&gt; (a -&gt; IO a) -&gt; a -&gt; IORef (IO ()) -&gt; IO a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; IO a
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span>
</span><span id="line-39"></span><span>    </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span id="local-6989586621679037858"><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO (a -&gt; b)
</span><a href="#local-6989586621679037858"><span class="hs-identifier hs-var">mf</span></a></span></span><span> </span><span id="local-6989586621679037857"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. STM (a -&gt; b) -&gt; STM a -&gt; STM b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;*&gt;</span></a></span></span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span id="local-6989586621679037856"><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037856"><span class="hs-identifier hs-var">mx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IORef (IO ()) -&gt; IO b) -&gt; STM b
forall a. (IORef (IO ()) -&gt; IO a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="annot"><span class="annottext">((IORef (IO ()) -&gt; IO b) -&gt; STM b)
-&gt; (IORef (IO ()) -&gt; IO b) -&gt; STM b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679037855"><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037855"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO (a -&gt; b)
</span><a href="#local-6989586621679037858"><span class="hs-identifier hs-var">mf</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037855"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">IO (a -&gt; b) -&gt; IO a -&gt; IO b
forall (f :: * -&gt; *) a b. Applicative f =&gt; f (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037856"><span class="hs-identifier hs-var">mx</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037855"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679037850"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-42"></span><span>    </span><span id="local-6989586621679037846"><span class="annot"><span class="annottext">return :: forall a. a -&gt; STM a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var hs-var hs-var hs-var">return</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; STM a
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span>
</span><span id="line-43"></span><span>    </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span id="local-6989586621679037843"><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037843"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679037842"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. STM a -&gt; (a -&gt; STM b) -&gt; STM b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621679037841"><span class="annot"><span class="annottext">a -&gt; STM b
</span><a href="#local-6989586621679037841"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IORef (IO ()) -&gt; IO b) -&gt; STM b
forall a. (IORef (IO ()) -&gt; IO a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="annot"><span class="annottext">((IORef (IO ()) -&gt; IO b) -&gt; STM b)
-&gt; (IORef (IO ()) -&gt; IO b) -&gt; STM b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679037840"><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037840"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-44"></span><span>        </span><span id="local-6989586621679037839"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037839"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037843"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037840"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-45"></span><span>        </span><span class="annot"><span class="annottext">STM b -&gt; IORef (IO ()) -&gt; IO b
forall a. STM a -&gt; IORef (IO ()) -&gt; IO a
</span><a href="Control.Sequential.STM.html#unSTM"><span class="hs-identifier hs-var">unSTM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; STM b
</span><a href="#local-6989586621679037841"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037839"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037840"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span id="local-6989586621679037939"><span class="annot"><a href="Control.Sequential.STM.html#atomically"><span class="hs-identifier hs-type">atomically</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037939"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679037939"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-48"></span><span id="atomically"><span class="annot"><span class="annottext">atomically :: forall a. STM a -&gt; IO a
</span><a href="Control.Sequential.STM.html#atomically"><span class="hs-identifier hs-var hs-var">atomically</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span id="local-6989586621679037835"><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037835"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-49"></span><span>    </span><span id="local-6989586621679037834"><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037834"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO (IORef (IO ()))
forall a. a -&gt; IO (IORef a)
</span><a href="../../base/src/GHC.IORef.html#newIORef"><span class="hs-identifier hs-var">newIORef</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-50"></span><span>    </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037835"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037834"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">IO a -&gt; IO () -&gt; IO a
forall a b. IO a -&gt; IO b -&gt; IO a
</span><a href="../../base/src/Control.Exception.Base.html#onException"><span class="hs-operator hs-var">`onException`</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-51"></span><span>        </span><span id="local-6989586621679037831"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679037831"><span class="hs-identifier hs-var">rollback</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO (IO ())
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037834"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-52"></span><span>        </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679037831"><span class="hs-identifier hs-var">rollback</span></a></span><span>
</span><span id="line-53"></span><span>
</span><span id="line-54"></span><span class="hs-comment">-- | @since 2.2.0</span><span>
</span><span id="line-55"></span><span id="local-6989586621679037931"><span id="local-6989586621679037933"><span class="annot"><a href="Control.Sequential.STM.html#throwSTM"><span class="hs-identifier hs-type">throwSTM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#Exception"><span class="hs-identifier hs-type">Exception</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037933"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679037933"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037931"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-56"></span><span id="throwSTM"><span class="annot"><span class="annottext">throwSTM :: forall e a. Exception e =&gt; e -&gt; STM a
</span><a href="Control.Sequential.STM.html#throwSTM"><span class="hs-identifier hs-var hs-var">throwSTM</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IORef (IO ()) -&gt; IO a) -&gt; STM a
forall a. (IORef (IO ()) -&gt; IO a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="annot"><span class="annottext">((IORef (IO ()) -&gt; IO a) -&gt; STM a)
-&gt; (e -&gt; IORef (IO ()) -&gt; IO a) -&gt; e -&gt; STM a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">IO a -&gt; IORef (IO ()) -&gt; IO a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">(IO a -&gt; IORef (IO ()) -&gt; IO a)
-&gt; (e -&gt; IO a) -&gt; e -&gt; IORef (IO ()) -&gt; IO a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">e -&gt; IO a
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#throwIO"><span class="hs-identifier hs-var">throwIO</span></a></span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span id="local-6989586621679037925"><span id="local-6989586621679037926"><span class="annot"><a href="Control.Sequential.STM.html#catchSTM"><span class="hs-identifier hs-type">catchSTM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exception.Type.html#Exception"><span class="hs-identifier hs-type">Exception</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037926"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037925"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679037926"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037925"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037925"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-59"></span><span id="catchSTM"><span class="annot"><span class="annottext">catchSTM :: forall e a. Exception e =&gt; STM a -&gt; (e -&gt; STM a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#catchSTM"><span class="hs-identifier hs-var hs-var">catchSTM</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span id="local-6989586621679037814"><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037814"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679037813"><span class="annot"><span class="annottext">e -&gt; STM a
</span><a href="#local-6989586621679037813"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IORef (IO ()) -&gt; IO a) -&gt; STM a
forall a. (IORef (IO ()) -&gt; IO a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="annot"><span class="annottext">((IORef (IO ()) -&gt; IO a) -&gt; STM a)
-&gt; (IORef (IO ()) -&gt; IO a) -&gt; STM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679037812"><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037812"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-60"></span><span>    </span><span id="local-6989586621679037811"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679037811"><span class="hs-identifier hs-var">old_rollback</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO (IO ())
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037812"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-61"></span><span>    </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO () -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037812"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-62"></span><span>    </span><span id="local-6989586621679037809"><span class="annot"><span class="annottext">Either e a
</span><a href="#local-6989586621679037809"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO a -&gt; IO (Either e a)
forall e a. Exception e =&gt; IO a -&gt; IO (Either e a)
</span><a href="../../base/src/Control.Exception.Base.html#try"><span class="hs-identifier hs-var">try</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO a
</span><a href="#local-6989586621679037814"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037812"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-63"></span><span>    </span><span id="local-6989586621679037807"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679037807"><span class="hs-identifier hs-var">rollback_m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO (IO ())
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037812"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-64"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Either e a
</span><a href="#local-6989586621679037809"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-65"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621679037806"><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679037806"><span class="hs-identifier hs-var">ex</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-66"></span><span>            </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679037807"><span class="hs-identifier hs-var">rollback_m</span></a></span><span>
</span><span id="line-67"></span><span>            </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO () -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037812"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679037811"><span class="hs-identifier hs-var">old_rollback</span></a></span><span>
</span><span id="line-68"></span><span>            </span><span class="annot"><span class="annottext">STM a -&gt; IORef (IO ()) -&gt; IO a
forall a. STM a -&gt; IORef (IO ()) -&gt; IO a
</span><a href="Control.Sequential.STM.html#unSTM"><span class="hs-identifier hs-var">unSTM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">e -&gt; STM a
</span><a href="#local-6989586621679037813"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679037806"><span class="hs-identifier hs-var">ex</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037812"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-69"></span><span>        </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621679037805"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037805"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-70"></span><span>            </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; IO () -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037812"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679037807"><span class="hs-identifier hs-var">rollback_m</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679037811"><span class="hs-identifier hs-var">old_rollback</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-71"></span><span>            </span><span class="annot"><span class="annottext">a -&gt; IO a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037805"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-72"></span><span>
</span><span id="line-73"></span><span class="hs-keyword">newtype</span><span> </span><span id="TVar"><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-var">TVar</span></a></span></span><span> </span><span id="local-6989586621679037915"><span class="annot"><a href="#local-6989586621679037915"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="TVar"><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-var">TVar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IORef.html#IORef"><span class="hs-identifier hs-type">IORef</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037915"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679037797"><span id="local-6989586621679037802"><span class="annot"><span class="annottext">TVar a -&gt; TVar a -&gt; Bool
(TVar a -&gt; TVar a -&gt; Bool)
-&gt; (TVar a -&gt; TVar a -&gt; Bool) -&gt; Eq (TVar a)
forall a. TVar a -&gt; TVar a -&gt; Bool
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: TVar a -&gt; TVar a -&gt; Bool
$c/= :: forall a. TVar a -&gt; TVar a -&gt; Bool
== :: TVar a -&gt; TVar a -&gt; Bool
$c== :: forall a. TVar a -&gt; TVar a -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span id="local-6989586621679037914"><span class="annot"><a href="Control.Sequential.STM.html#newTVar"><span class="hs-identifier hs-type">newTVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679037914"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037914"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-77"></span><span id="newTVar"><span class="annot"><span class="annottext">newTVar :: forall a. a -&gt; STM (TVar a)
</span><a href="Control.Sequential.STM.html#newTVar"><span class="hs-identifier hs-var hs-var">newTVar</span></a></span></span><span> </span><span id="local-6989586621679037792"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037792"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IORef (IO ()) -&gt; IO (TVar a)) -&gt; STM (TVar a)
forall a. (IORef (IO ()) -&gt; IO a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO (TVar a) -&gt; IORef (IO ()) -&gt; IO (TVar a)
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; IO (TVar a)
forall a. a -&gt; IO (TVar a)
</span><a href="Control.Sequential.STM.html#newTVarIO"><span class="hs-identifier hs-var">newTVarIO</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037792"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span id="local-6989586621679037912"><span class="annot"><a href="Control.Sequential.STM.html#newTVarIO"><span class="hs-identifier hs-type">newTVarIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679037912"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037912"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-80"></span><span id="newTVarIO"><span class="annot"><span class="annottext">newTVarIO :: forall a. a -&gt; IO (TVar a)
</span><a href="Control.Sequential.STM.html#newTVarIO"><span class="hs-identifier hs-var hs-var">newTVarIO</span></a></span></span><span> </span><span id="local-6989586621679037789"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037789"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-81"></span><span>    </span><span id="local-6989586621679037788"><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037788"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; IO (IORef a)
forall a. a -&gt; IO (IORef a)
</span><a href="../../base/src/GHC.IORef.html#newIORef"><span class="hs-identifier hs-var">newIORef</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037789"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-82"></span><span>    </span><span class="annot"><span class="annottext">TVar a -&gt; IO (TVar a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IORef a -&gt; TVar a
forall a. IORef a -&gt; TVar a
</span><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-var">TVar</span></a></span><span> </span><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037788"><span class="hs-identifier hs-var">ref</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span id="local-6989586621679037910"><span class="annot"><a href="Control.Sequential.STM.html#readTVar"><span class="hs-identifier hs-type">readTVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037910"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037910"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-85"></span><span id="readTVar"><span class="annot"><span class="annottext">readTVar :: forall a. TVar a -&gt; STM a
</span><a href="Control.Sequential.STM.html#readTVar"><span class="hs-identifier hs-var hs-var">readTVar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span id="local-6989586621679037787"><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037787"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IORef (IO ()) -&gt; IO a) -&gt; STM a
forall a. (IORef (IO ()) -&gt; IO a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO a -&gt; IORef (IO ()) -&gt; IO a
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IORef a -&gt; IO a
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037787"><span class="hs-identifier hs-var">ref</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span>
</span><span id="line-87"></span><span class="hs-comment">-- | @since 2.1.2</span><span>
</span><span id="line-88"></span><span id="local-6989586621679037908"><span class="annot"><a href="Control.Sequential.STM.html#readTVarIO"><span class="hs-identifier hs-type">readTVarIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037908"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="#local-6989586621679037908"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-89"></span><span id="readTVarIO"><span class="annot"><span class="annottext">readTVarIO :: forall a. TVar a -&gt; IO a
</span><a href="Control.Sequential.STM.html#readTVarIO"><span class="hs-identifier hs-var hs-var">readTVarIO</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span id="local-6989586621679037786"><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037786"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef a -&gt; IO a
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037786"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-90"></span><span>
</span><span id="line-91"></span><span id="local-6989586621679037906"><span class="annot"><a href="Control.Sequential.STM.html#writeTVar"><span class="hs-identifier hs-type">writeTVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037906"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679037906"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-type">STM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-92"></span><span id="writeTVar"><span class="annot"><span class="annottext">writeTVar :: forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="Control.Sequential.STM.html#writeTVar"><span class="hs-identifier hs-var hs-var">writeTVar</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Sequential.STM.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span id="local-6989586621679037782"><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037782"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679037781"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037781"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IORef (IO ()) -&gt; IO ()) -&gt; STM ()
forall a. (IORef (IO ()) -&gt; IO a) -&gt; STM a
</span><a href="Control.Sequential.STM.html#STM"><span class="hs-identifier hs-var">STM</span></a></span><span> </span><span class="annot"><span class="annottext">((IORef (IO ()) -&gt; IO ()) -&gt; STM ())
-&gt; (IORef (IO ()) -&gt; IO ()) -&gt; STM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679037780"><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037780"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-93"></span><span>    </span><span id="local-6989586621679037779"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037779"><span class="hs-identifier hs-var">oldval</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef a -&gt; IO a
forall a. IORef a -&gt; IO a
</span><a href="../../base/src/GHC.IORef.html#readIORef"><span class="hs-identifier hs-var">readIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037782"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-94"></span><span>    </span><span class="annot"><span class="annottext">IORef (IO ()) -&gt; (IO () -&gt; IO ()) -&gt; IO ()
forall a. IORef a -&gt; (a -&gt; a) -&gt; IO ()
</span><a href="../../base/src/Data.IORef.html#modifyIORef"><span class="hs-identifier hs-var">modifyIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (IO ())
</span><a href="#local-6989586621679037780"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IORef a -&gt; a -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037782"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037779"><span class="hs-identifier hs-var">oldval</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-95"></span><span>    </span><span class="annot"><span class="annottext">IORef a -&gt; a -&gt; IO ()
forall a. IORef a -&gt; a -&gt; IO ()
</span><a href="../../base/src/GHC.IORef.html#writeIORef"><span class="hs-identifier hs-var">writeIORef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef a
</span><a href="#local-6989586621679037782"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037781"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-96"></span></pre></body></html>